<template>
 <div>
    <div class="search-con search-con-top">
      <div class="fl">
        <!-- <Input clearable placeholder="输入会员名称搜索" class="search-input" v-model.trim="search.nickname"/> -->
        <Input clearable placeholder="输入商家名称搜索" class="search-input" v-model.trim="search.bname"/>
        <!-- <Select v-model="search.type" clearable placeholder="按状态搜索" class="search-col" style="width:200px">
          <Option :value="0">用户领取</Option>
          <Option :value="1">平台发放</Option>
          <Option :value="2">充值赠送</Option>
          <Option :value="3">租赁赠送</Option>
          <Option :value="4">线上购物赠送</Option>
          <Option :value="5">线下购物赠送</Option>
          <Option :value="6">线下购物使用</Option>
        </Select> -->
        <Button class="search-btn" type="primary" @click="getUserCouponList">搜索</Button>
      </div>
    </div>
    <tables ref="tables" editable :border="true" v-model="tableData" :columns="columns" :page="page" @pageSize="pageSize" @pageNum="pageNum"/>
 </div>
</template>

<script>
import Tables from "_c/tables";
import { userOrderL ,userOrderS , userCouponList } from "@/api/data";

 export default {
   data () {
     return {
       tableData:[],
       columns:[
            {
                type: "index",
                width: 60,
                align: "center",
                key: ""
            },
            {
                title: "商家名称",
                key: "bname"
            },
            // {
            //     title: "时间",
            //     key: "createtm"
            // },
            // {
            //     title: "客户名称",
            //     key: "nickname"
            // },
            {
                title: "类型",
                key: "type",
                render:(h,params)=>{
                    let text = ''
                    switch (params.row.type) {
                        case 0:
                            text = '用户领取'
                            break;
                        case 1:
                            text = '平台发放'
                            break;
                        case 2:
                            text = '充值赠送'
                            break;
                        case 3:
                            text = '租赁赠送'
                            break;
                        case 4:
                            text = '线上购物赠送'
                            break;
                        case 5:
                            text = '线下购物赠送'
                            break;
                        case 6:
                            text = '线下购物使用'
                            break;
                        default:
                            break;
                    }
                    return h('div',text)
                }
            },
            {
                title: "点金券金额",
                key: "money"
            },
            {
              title: "预计总金额",
              key: "totalMoney"
            }
       ],
       page:{
            current: 1,
            total: 0,
            pageSize: 10
       },
       search:{
        //    nickname:'',
        //    gname:''
       }
     }
   },
   methods: {
     pageSize(value){
        this.page.pageSize = value
        this.page.current = 1
        this.getUserCouponList()
     },
     pageNum(value){
        this.page.current = value
        this.getUserCouponList()
     },
     getUserCouponList(){
         let options = {
            nickname:this.search.nickname,
            bname:this.search.bname,
            type:this.search.type,
            pageNum:this.page.current,
            pageSize:this.page.pageSize
         }
         userCouponList(options).then(res=>{
             if(res.code == 1){
                this.tableData = res.data.data
                this.tableData.forEach(ele => {
                 ele.totalMoney = ele.totalMoney ? ele.totalMoney :0
                });
                 this.page.total = res.data.total
             }
         })
     }
   },
   mounted() {
       this.getUserCouponList()
   },
   components: {
      tables: Tables
   }
 }
</script>

<style>


</style>
